/**
 * Created by wujo5 on 1/19/2018.
 */
'use strict';
var moment = require('moment');
var uuid = require('node-uuid');
var testCases = require('../models/testcases');
var testCaseRegistration = require('../models/testCaseRegistration');
var testSuit = require('../models/testSuit');
var commonMethods = require('../utils/commonMethods');
var testCasesModel = testCases.testcases;
var testCaseRegistrationModel = testCaseRegistration.testCaseRegistration;
var testSuitModel = testSuit.testSuit;
var bizKeyCtrl = require('../controller/bizKeyController');
var testcaseRelationshipCtrl = require('../controller/testcaseRelationshipController');


var addTestCase = async function (data, success, error) {
    var testCaseId = uuid.v4();
    if(data.relationship.dependency.length == 0) {
        data.isReady = true;
    }
    var testCaseSave = new testCasesModel({
        testCaseId: testCaseId,
        testCaseName: data.testCaseName,
        bizKey: data.bizKey,
        msgIn: data.msgIn,
        msgOut: data.msgOut,
        inQueue: data.inQueue,
        outQueue: data.outQueue,
        verifiers: data.verifiers,
        urls: data.urls,
        tags: data.tags,
        create_date: moment(new Date()).format('DD MMM YYYY HH:mm'),
        last_update_date: '',
        isReady:data.isReady
    });
    testCaseSave.save(async function (err, docs) {
        if (err) {
            error({status: "400", error: err});
        } else {
            docs.relatedData = await testcaseRelationshipCtrl.addRelationship(data, testCaseId);
            success({status: '200', data: docs})
        }
    });
};

var updateTestCase = async function (data, success, error) {
    data.last_update_date = moment(new Date()).format('DD MMM YYYY HH:mm');
    if(data.relationship && data.relationship.dependency && data.relationship.dependency.length == 0) {
        data.isReady = true;
    }
    var conditions = {testCaseId: data.testCaseId};
    testCasesModel.update(conditions, data, async function (err, docs) {
        if (err) {
            error({status: "400", error: err});
        } else {
            docs.relatedData = await testcaseRelationshipCtrl.updateRelationship(data, conditions);
            success({data: docs});
        }
    })
};

var findTestCaseByMultiTags =async function (data, tags, success, error) {
    testCasesModel.find({tags: {$in: tags}},async function (err, testCaseList) {
        let testcaseVOs = [];
        if (err) {
            error({status: '400', reason: err})
        } else {
            for (let testCase of testCaseList) {
                let relationship = await testcaseRelationshipCtrl.getRelationshipByTestcaseId(testCase.testCaseId);
                testcaseVOs.push(convertToVo(testCase, relationship ? relationship : {}));
            }
            commonMethods.getFilterPageList(data, testcaseVOs, success);
        }
    })
};


var findTestCaseByUniqueTags = async function (data, success, error) {
    testCasesModel.find({tags: data.tags}, async function (err, testCaseList) {
        let testcaseVOs = [];
        if (err) {
            error({status: '400', reason: err})
        } else {
            for (let testCase of testCaseList) {
                let relationship = await testcaseRelationshipCtrl.getRelationshipByTestcaseId(testCase.testCaseId);
                testcaseVOs.push(convertToVo(testCase, relationship ? relationship : {}));
            }
            commonMethods.getFilterPageList(data, testcaseVOs, success);
        }
    })
};

var findAllTestCasePageList = async function (data, success, error) {
    testCasesModel.find(async function (err, testCaseList) {
        let testcaseVOs = [];
        if (err) {
            error({status: "400", reason: err});
        } else {
            for (let testCase of testCaseList) {
                let relationship = await testcaseRelationshipCtrl.getRelationshipByTestcaseId(testCase.testCaseId);
                testcaseVOs.push(convertToVo(testCase, relationship ? relationship : {}));
            }
            commonMethods.getFilterPageList(data, testcaseVOs, success);
        }
    });
};

var convertToVo = function (testcaseData, relationshipData) {
    var testcaseVo = {
        testCaseId: testcaseData.testCaseId,
        testCaseName: testcaseData.testCaseName,
        relationship: relationshipData,
        bizKey: testcaseData.bizKey,
        msgIn: testcaseData.msgIn,
        msgOut: testcaseData.msgOut,
        inQueue: testcaseData.inQueue,
        outQueue: testcaseData.outQueue,
        verifiers: testcaseData.verifiers,
        urls: testcaseData.urls,
        tags: testcaseData.tags,
        isReady:testcaseData.isReady,
        create_date: testcaseData.create_date,
        last_update_date: testcaseData.last_update_date,
    };
    return testcaseVo;
}

var getTestCasePageList = function (data, success, error) {
    if (data.tags) {
        if (data.tags.indexOf(',') !== -1) {
            var tags = data.tags.split(",");
            findTestCaseByMultiTags(data, tags, success, error);
        } else {
            findTestCaseByUniqueTags(data, success, error);
        }
    } else {
        findAllTestCasePageList(data, success, error);
    }
};

var removeTestCase = function (data, success, error) {
    testCasesModel.remove({testCaseId: data.testCaseId}, function (err, result) {
        if (err) {
            error({status: 400, reason: err})
        } else {
            success({status: '200'});
        }
    })
};

var batchRemoveTestCase = function (data, success, error) {
    var testCaseIdArr = data.testCaseIds.split(',');
    testCasesModel.remove({testCaseId: {$in: testCaseIdArr}}, function (err) {
        if (err) {
            error({status: '400', reason: err})
        } else {
            success({status: '200'});
        }
    })
};

var getTagList = function (success, error) {
    var tagArr = [];
    var tags = [];
    var distinctTags = [];
    testCasesModel.find(function (err, data) {
        if (err) {
            error({status: "400", reason: err});
        } else {
            data.forEach(function (item) {
                tagArr.push(item.tags);
            })
            tagArr.forEach(function (item) {
                item.forEach(function (item1) {
                    tags.push(item1);
                })
            })
            tags.forEach(function (item, index) {
                if (tags.indexOf(item, index + 1) === -1) {
                    distinctTags.push(item);
                }
            })
            success(distinctTags);
        }
    })
};

var checkTestCaseName = function (data, success, error) {
    let testCaseName = {
        testCaseName: {$regex: '^'+data.testCaseName+'$', $options:'i'} //忽略大小写进行查找,操作符"i"表示“不区分大小写”
    };
    testCasesModel.findOne(testCaseName, function (err, result) {
        if (err) {
            error({status: '400', reason: err})
        } else {
            success({status: '200', data: result})
        }
    });
};

const _ = require('lodash');

function getByName(req, res, next) {
    let name = req.params.name;
    if (_.isEmpty(name)) {
        res.send({status: "400", message: 'testCaseName is Empty'});
    } else {
        testCasesModel.findOne({
            testCaseName: name
        }, function (err, data) {
            if (err) {
                next(err);
            } else {
                if (_.isEmpty(data)) {
                    res.send({status: "400", message: 'not this data'});
                } else {
                    res.send({status: "200", data: data});
                }
            }
        });
    }
}

function getLWmapping(req, res, next) {
    let testCaseId = req.body.testCaseId;
    let expectedurl = req.body.url;

    if (_.isEmpty(testCaseId) || _.isEmpty(expectedurl)) {
        res.send({status: "400", message: 'POST data is empty'});
    } else {
        testCasesModel.findOne({
            testCaseId: testCaseId
        }, function (err, data) {
            if (err) {
                next(err);
            } else {
                if (_.isEmpty(data)) {
                    res.send({status: "400", message: 'no this data with testCaseId :' + testCaseId})
                } else {
                    let response = filterURLs(data.urls, {url: expectedurl}, 'restful');
                    res.send({status: '200', data: response});
                }
            }
        });
    }
}

function getSoapmapping(req, res, next) {
    let testCaseId = req.body.testCaseId;
    let expectedUrl = req.body.url;
    let expectedMethod = req.body.soapmethod;
    let expetedParams = req.body.params;

    if (_.isEmpty(testCaseId) || _.isEmpty(expectedUrl) || _.isEmpty(expectedMethod)) {
        res.send({status: '400', messsage: 'POST data is empty'});
    } else {
        testCasesModel.findOne({
            testCaseId: testCaseId
        }, function (err, data) {
            if (err)
                next(err);
            else {
                if (_.isEmpty(data))
                    res.send({status: '400', message: 'no this data with testCaseId :' + testCaseId})
                else {
                    let response = filterURLs(data.urls, {
                        url: expectedUrl,
                        method: expectedMethod,
                        params: expetedParams
                    }, 'soap');
                    res.send({status: '200', data: response});
                }
            }
        });
    }
}

function getRegisterTestCase(req, res, next) {
    testCaseRegistrationModel.find(function (err, data) {
        if (err) {
            next(err);
        } else {
            res.send({status: '200', data: data});
        }
    });
}

function replaceBizKeyToValueForMsgOut (testcase) {  //need replace all the test case with bizkey & value
  var newMsgOutStr = commonMethods.replaceSourceDataWithKeyValue(JSON.stringify(testcase.msgOut), testcase.bizKey);
  var newMsgInStr = commonMethods.replaceSourceDataWithKeyValue(JSON.stringify(testcase.msgIn), testcase.bizKey);
  var newMsgOut = JSON.parse(newMsgOutStr);
  var newMsgIn = JSON.parse(newMsgInStr);
  testcase.msgOut = newMsgOut;
  testcase.msgIn = newMsgIn;
}

function getByTestCaseId(req, res, next) {
    let testcaseId = req.params.testcaseId;

    testCasesModel.findOne({testCaseId: testcaseId}, function (err, data) {
        if (err) {
            next(err);
        } else {
            if(data){
                replaceBizKeyToValueForMsgOut(data);
            }
            res.send({status: '200', data: data});
        }
    });
}

var getAll = async function(success, error) {
    testCasesModel.find(async function (err, testCaseList) {
        var testcaseVOs = [];
        if (err) {
            error({status: "400", reason: err});
        } else {
            for (let testCase of testCaseList) {
                let relationship = await testcaseRelationshipCtrl.getRelationshipByTestcaseId(testCase.testCaseId);
                testcaseVOs.push(convertToVo(testCase, relationship ? relationship : {}));
            }
            replaceBizKeysWithValue(testcaseVOs, success);
        }
    })
};
var getAllReadyTestCaseList =function (success, error) {
    testCasesModel.find({isReady:true}, function (err, data) {
        if (err) {
            error({reason: err});
        } else {
            replaceBizKeysWithValue(data, success);
        }
    })
}
function filterURLs(urls, expected, type) {
    if (_.isEmpty(urls))
        return;
    else {
        if (_.isEqual(type, 'restful')) {
            for (let index in urls) {
                let flag = true;
                if (!_.isEqual(urls[index].url, expected.url))
                    flag = false;
                if (flag)
                    return urls[index];
            }
        } else if (_.isEqual(type, 'soap')) {
            for (let index in urls) {
                let cu_u = urls[index];
                if (_.isEqual(cu_u.type, 'soap')) {
                    let flag = true;
                    if (!_.isEqual(cu_u.url, expected.url) && flag)
                        flag = false;
                    if (!_.isEqual(cu_u.soapMethod, expected.method) && flag)
                        flag = false;
                    if (!_.isEmpty(cu_u.params) && !_.isEmpty(expected.params) && flag) {
                        let paramRefObj = JSON.parse(cu_u.params);
                        let paramToObj = JSON.parse(expected.params);
                        if (!_.isEqual(paramRefObj, paramToObj)) {
                            flag = false;
                        }
                    }
                    if (flag)
                        return cu_u;
                }
            }
        }
    }
}

var registerTestCase = function (data, success, error) {
    console.log(data.registrationId);
    var testCaseRegistration = new testCaseRegistrationModel({
        _id: data.registrationId,
        testCaseId: data.testCaseId,
        status: data.status,
        testSuitId: data.testSuitId,
        taskType : data.taskType,
        orderNum : data.orderNum,
        prepareFor : data.prepareFor,
    });

    testCaseRegistration.save(function (err) {
        if (err) {
            error({'testCaseSaveStatus': "400", 'error': err});
        } else {
            success({'testCaseSaveStatus': '200'})
            console.log("insert Test Case Registration Successful");
        }
    });
}

var registerTestSuit = function (data, success, error) {
    var testSuit = new testSuitModel({
        _id: data.testSuitId,
        status: data.status,
        createdDate: moment(new Date()).format('DD MMM YYYY HH:mm'),
        updatedDate: moment(new Date()).format('DD MMM YYYY HH:mm'),
    });

    testSuit.save(function (err) {
        if (err) {
            error({'testSuitSaveStatus': "400", 'error': err});
        } else {
            success({'testSuitSaveStatus': '200'})
            console.log("insert Test Suit Successful");
        }
    });
}

function getTestSuitByStatus(req, res, next) {
    var status = req.params.status;
    testSuitModel.find({status: status}, function (err, records) {
        if (err) {
            res.send({status: '500'})
        } else {
            res.send({status: '200', data: records})
        }
    })
}

function updateTestSuitStatus(req, res, next) {
    var testsuitId = req.body.testsuitId;
    var status = req.body.status;
    if (_.isEmpty(testsuitId) || _.isEmpty(status)) {
        res.send({status: "400", message: 'POST data is empty'})
    } else {
        var update = {status: status};
        testSuitModel.update({'_id': testsuitId}, update, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'update error'})
            } else {
                res.send({status: '200', data: result, message: 'update successfully'})
            }
        })
    }
}

function updateTestSuitsStatus(req, res, next) {
    var testsuitIds = JSON.parse(req.body.testsuitIds);
    var status = req.body.status;
    if (_.isEmpty(testsuitIds) || _.isEmpty(status)) {
        res.send({status: "400", message: 'POST data is empty'})
    } else {
        var update = {'status': status};
        testSuitModel.update({'_id': {'$in': testsuitIds}}, update, {multi: true}, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'update error'})
            } else {
                res.send({status: '200', data: result, message: 'update successfully'})
            }
        })
    }
}


function updateTestCaseRegByTestSuitIds(req, res, next) {
    var testsuitIds = JSON.parse(req.body.testsuitIds);
    var status = req.body.status;
    if (_.isEmpty(testsuitIds) || _.isEmpty(status)) {
        res.send({status: "400", message: 'POST data is empty'})
    } else {
        var update = {'status': status};
        testCaseRegistrationModel.update({'testSuitId': {'$in': testsuitIds}}, update, {multi: true}, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'update error'})
            } else {
                res.send({status: '200', data: result, message: 'update successfully'})
            }
        })
    }
}


function updateRegistrationStatusById(data, success, error) {
    var id = data.testCaseRegistrationId[0];
    var status = data.status[0];
    if (_.isEmpty(id) || _.isEmpty(status)) {
        error({status: "400", message: 'POST data is empty'});
    } else {
        var update = {'status': status};
        testCaseRegistrationModel.update({'_id': id}, update, {multi: true}, function (err, result) {
            if (err) {
                error({status: '500', message: 'update error'})
            } else {
                success({status: '200', data: result, message: 'update successfully'})
            }
        })
    }

}

function updateRegistrationByIds(req, res, next){
    var ids = req.body.ids;
    var status = req.body.status;
    if (_.isEmpty(ids)) {
        res.send({status: "400", message: 'ids is empty'})
    } else if (_.isEmpty(status)) {
        res.send({status: "400", message: 'status is empty'})
    } else {
        ids = JSON.parse(req.body.ids);
        var update = {'status': status};
        testCaseRegistrationModel.update({'_id': {'$in': ids}}, update, {multi: true}, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'update error'})
            } else {
                res.send({status: '200', data: result, message: 'updateRegistrationByIds successfully'})
            }
        })
    }
}

function getTestcaseRegByTestSuitId(req, res, next) {
    var testsuitId = req.params.testsuitId;
    if (_.isEmpty(testsuitId)) {
        res.send({status: "400", message: 'params is empty'})
    } else {
        testCaseRegistrationModel.find({testSuitId: testsuitId}, function (err, testsuit) {
            if (err) {
                res.send({status: '500', message: 'find error'})
            } else {
                res.send({status: '200', data: testsuit})
            }
        })
    }
}

function replaceBizKeysWithValue(data, callback) {
    var result = [];
    if (data) {
        data.forEach(function (testcase) {
            result.push(JSON.parse(commonMethods.replaceSourceDataWithKeyValue(JSON.stringify(testcase), testcase.bizKey)));
        });
        callback(result);
    }
}

function getRegisterTestCaseBystatus(req, res, next) {
    var status = req.params.status;
    if (_.isEmpty(status)) {
        res.send({status: "400", message: 'params status is empty'})
    } else {
        testCaseRegistrationModel.find({status: status}, function (err, tcRegistrations) {
            if (err) {
                res.send({status: '500', message: 'find error'})
            } else {
                res.send({status: '200', data: tcRegistrations})
            }
        })
    }
}

function fetchRegistrationByStatusAndLteDate(req, res, next){
    var status = req.body.status;
    var lteDate = req.body.lteDate;
    //console.log(lteDate)
    if (_.isEmpty(status)) {
        res.send({status: "400", message: 'status is empty'})
    }else if(_.isEmpty(lteDate)){
        res.send({status: "400", message: 'lteDate is empty'})
    } else {
        testCaseRegistrationModel.find({
            'status': status,
            'expectedRunningTime': {
                '$lte': new Date(lteDate)
            }
        }, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'find error'})
            } else {
                    //console.log(result)
                    res.send({status: '200', data: result, message: 'fetchRegistrationByStatusAndLteDate successfully'})
            }
        })
    }
}

function updateRegistrationWithExpectedDate(req, res, next){
    var status = req.body.status;
    var _id = req.body._id;
    var expectedRunningTime = req.body.expectedRunningTime;
    console.log(new Date(expectedRunningTime))
    if (_.isEmpty(status)) {
        res.send({status: "400", message: 'status is empty'})
    } else if (_.isEmpty(expectedRunningTime)) {
        res.send({status: "400", message: 'expectedRunningTime is empty'})
    } else {
        testCaseRegistrationModel.update({'_id': _id}, {
            'status': status,
            'expectedRunningTime': new Date(expectedRunningTime)
        }, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'update error'})
            } else {
                    res.send({status: '200', data: result, message: 'update updateRegistrationWithExpectedDate successfully'})
            }
        })
    }
}

function asyncGetTestCaseById(testCaseId) {
    return new Promise(function (resolve, reject) {
        testCasesModel.findOne({testCaseId: testCaseId}, function (err, data) {
            if (err) {
                reject(err);
            } else {
                resolve(data);
            }

        })
    })

}

var getReplacedBizKeyTestCase = async function (req, res, next) {
    var testCaseId = req.params.testCaseId;
    var prepareFor = req.params.prepareFor;
    if (_.isEmpty(testCaseId)) {
        res.send({status: "400", message: 'testCaseId is empty'})
    } else if (_.isEmpty(prepareFor)) {
        res.send({status: "400", message: 'prepareFor is empty'})
    } else {
        var destination = await asyncGetTestCaseById(testCaseId);
        var source = await asyncGetTestCaseById(prepareFor);
        destination.msgIn = commonMethods.replaceSourceDataWithKeyValue(destination.msgIn, source.bizKey);
        var newMsgOutStr = commonMethods.replaceSourceDataWithKeyValue(JSON.stringify(destination.msgOut), source.bizKey);
        var newMsgOut = JSON.parse(newMsgOutStr);
        destination.msgOut = newMsgOut;
        console.log(JSON.stringify(destination));
        res.send(destination);
    }
};

function getRegistrationsByTestSuitIdAndStatus(req, res, next) {
    var status = 'New';
    var testSuitId = req.params.testSuitId;
    if (_.isEmpty(testSuitId)) {
        res.send({status: "400", message: 'testSuitId is empty'})
    } else {
        testCaseRegistrationModel.find({
            'status': status,
            'testSuitId': testSuitId
        }, function (err, result) {
            if (err) {
                res.send({status: '500', message: 'find error'})
            } else {
                res.send(result[0]);
            }
        }).sort({"orderNum": 1})
    }
}

function updateRegisterationStatusById(data, success, error) {
    var id = data.testCaseRegistrationId[0];
    var status = data.status[0];
    if (_.isEmpty(id) || _.isEmpty(status)) {
        error({status: "400", message: 'POST data is empty'});
    } else {
        var update = {'status': status};
        testCaseRegistrationModel.update({'_id': id}, update, {multi: true}, function (err, result) {
            if (err) {
                error({status: '500', message: 'update error'})
            } else {
                success({status: '200', data: result, message: 'update successfully'})
            }
        })
    }
}

function updateByStatusAndTestSuitId(req, res, next){
    let fromStatus = req.body.fromStatus;
    let toStatus = req.body.toStatus;
    let testSuitId = req.body.testSuitId;
    if (_.isEmpty(fromStatus) || _.isEmpty(toStatus) || _.isEmpty(testSuitId)) {
        res.send({status: "400", message: 'POST data is empty'});
    } else {
        let query = {'status': fromStatus, 'testSuitId':testSuitId};
        let update = {'status':toStatus};
        testCaseRegistrationModel.update(query, update, {multi: true}, function (err, result) {
            if (err) {
                res.send({status: '500', message: err})
            } else {
                res.send({status: '200', data: result})
            }
        })
    }
}

var getPrepareForByTestSuitId = function(req, res){
    let testSuitId = req.params.testSuitId;
    if(_.isEmpty(testSuitId)){
        res.send("testSuit Id empty");
    }else{
        testCaseRegistrationModel.findOne({testSuitId:testSuitId}, function(err, result){
            if(err){
                res.send("ERROR");
            }else{
                if(!result){
                    res.send("NOT FOUND");
                }else{
                    res.send(result.prepareFor);
                }

            }
        })
    }
};

var updateTestCaseToReady = function(req, res){
    let testCaseId = req.body.testCaseId;
    if(_.isEmpty(testCaseId)){
        res.send("testCaseId Id empty");
    }else{
        testCasesModel.update({testCaseId:testCaseId},{isReady:true}, function(err, result){
            if(err){
                res.send("ERROR");
            }else{
                res.send("SUCCESS");
            }
        })
    }
};
var getLightWeightTestCaseList = function(req, res){
    testCasesModel.find((err,result)=>{
        if(err){
            res.send("ERROR");
        }else{
            res.send(result.map(item => {return {testCaseId:item.testCaseId,testCaseName:item.testCaseName}}));
        }
    })
};


function getAllDependencyBizKeysByTestcaseIds(req, res, next) {
  if(!req.params.testcaseIds || req.params.testcaseIds ===''){
    res.send({status: '200', data: []});
    return;
  }
  let testCaseIds = req.params.testcaseIds.split(',');
  if (_.isEmpty(testCaseIds)) {
    res.send({status: "400", message: 'POST data is empty'})
  } else {
    testCasesModel.find({'testCaseId': {'$in': testCaseIds}}, function (err, result) {
      if (err) {
        res.send({status: '500', message: 'update error'})
      } else {
          let bizKeys = [];
        result.forEach(testcase=>{
          if(!testcase.bizKey){
              return;
          }else{
            testcase.bizKey.forEach(item=>{
                if(bizKeys.indexOf(item.bizKeyType) === -1){
                  bizKeys.push(item.bizKeyType);
                }
            })
          }
        })
        res.send({status: '200', data: bizKeys})
      }
    })
  }
}




module.exports = {
    getLightWeightTestCaseList:getLightWeightTestCaseList,
    removeTestCase: removeTestCase,
    addTestCase: addTestCase,
    updateTestCase: updateTestCase,
    getTestCasePageList: getTestCasePageList,
    getByName: getByName,
    getLWmapping: getLWmapping,
    getSoapmapping: getSoapmapping,
    registerTestCase: registerTestCase,
    registerTestSuit: registerTestSuit,
    getByTestCaseId: getByTestCaseId,
    checkTestCaseName: checkTestCaseName,
    getRegisterTestCase: getRegisterTestCase,
    batchRemoveTestCase: batchRemoveTestCase,
    getTestSuitByStatus: getTestSuitByStatus,
    getTagList: getTagList,
    updateTestSuitStatus: updateTestSuitStatus,
    updateTestSuitsStatus: updateTestSuitsStatus,
    getTestcaseRegByTestsuitId: getTestcaseRegByTestSuitId,
    updateTestCaseRegByTestSuitIds: updateTestCaseRegByTestSuitIds,
    getAll: getAll,
    getAllReadyTestCaseList:getAllReadyTestCaseList,
    getRegisterTestCaseBystatus: getRegisterTestCaseBystatus,
    updateRegistrationByIds:updateRegistrationByIds,
    fetchRegistrationByStatusAndLteDate : fetchRegistrationByStatusAndLteDate,
    updateRegistrationWithExpectedDate :updateRegistrationWithExpectedDate,
    getRegistrationsByTestSuitIdAndStatus: getRegistrationsByTestSuitIdAndStatus,
    getReplacedBizKeyTestCase:getReplacedBizKeyTestCase,
    updateRegisterationStatusById : updateRegisterationStatusById,
    updateByStatusAndTestSuitId: updateByStatusAndTestSuitId,
    getPrepareForByTestSuitId:getPrepareForByTestSuitId,
    updateTestCaseToReady:updateTestCaseToReady,
    getAllDependencyBizKeysByTestcaseIds:getAllDependencyBizKeysByTestcaseIds
}